var columns = {}

function calcColumnWidths(model, parent, parseTime, parseType )
{
    for (var i = 0; i < model.count; ++i)
    {
        var data = model.get(i)
        for (var key in data)
        {
            if (!columns[key]) {
                columns[key] = 0
            }

            var formattedData;
            if (key=="depTime" || key=="arrTime") {
                formattedData = parseTime(data[key])
            } else if (key=="type") {
                formattedData = parseType(data[key])
            } else {
                formattedData = data[key]
            }

            var textElement = Qt.createQmlObject(
                    'import Qt 4.7;'
                    + 'Text {'
                    + '   text: "' + formattedData + '" '
                    + '}',
                    parent, "calcColumnWidths")

            columns[key] = Math.max(textElement.width, columns[key])
            textElement.destroy()
        }
    }
    return columns
}
